package com.lvmama.rhino.common.entity

import java.util.Properties

import scala.util.matching.Regex


/**
  * Created by yuanxiaofeng on 2016/6/17.
  */
/**
  * @param name
  * @param partitions
  * @param replicationFactor
  * @param config
  */
case class KafkaTopic(name: String, partitions: Int = 3, replicationFactor: Int = 1,
                      config: Properties = new Properties()) {

  require(partitions > 0)
  require(replicationFactor > 0)
}

case class JobConfig(
                       spark: Map[String, String],
                       streamingCheckpointDir: Map[String, String],
                       sourceKafka: Map[String, String],
                       sinkKafka: Map[String, String],
                       redis: Map[String, String],
                       param: Map[String, String])

object JobConfig {

  import com.typesafe.config.{Config, ConfigFactory}
  import scala.collection.JavaConversions._

  type ConfigType = Map[String, String]

  def apply(): JobConfig = {
    apply(ConfigFactory.load)
  }

  def apply(applicationConfig: Config): JobConfig = {

    val config = applicationConfig.getConfig("defaultConfig")

    new JobConfig(
      transform2Map(config, "spark"),
      transform2Map(config, "streamingCheckpointDir"),
      transform2Map(config, "kafkaSource"),
      transform2Map(config, "kafkaSink"),
      transform2Map(config, "redis"),
      transform2Map(config, "param"))
  }

  private def transform2Map(config: Config, configName: String): ConfigType = {
    config.getObject(configName).unwrapped().toMap.asInstanceOf[ConfigType]
  }
}

//无线端页面类型
sealed trait PageTypeEnum{def code: String}
//case object INDEX extends PageTypeEnum{val code = "3Shou"} //首页 现首页属于频道页
case object CHANNEL extends PageTypeEnum{val code = "3PinD"} //频道页
case object SEARCH extends PageTypeEnum{val code = "3SouS"} //搜索页
case object SEARCH_PRE extends PageTypeEnum{val code = "3SouSb9c"} //搜索前置页
case object SEARCH_DETAIL extends PageTypeEnum{val code = "3SouSmda"} //搜索结果页
case object DETAIL extends PageTypeEnum{val code = "3XagQ"} //详情页
case object Fill_ORDER extends PageTypeEnum{val code = "3TXDD"} //填写订单页
case object PENDING_PAYMENT extends PageTypeEnum{val code = "3DaiZ"} //待支付
case object COMPLETED_PAYMENT extends PageTypeEnum{val code = "3ZhiW"} //支付完成页
case object TOPIC extends PageTypeEnum{val code = "3zhTi"} //专题页
case object REGISTER extends PageTypeEnum{val code = "3rq0f"} //注册页
case object SUPERFREETRAVEL_HP extends PageTypeEnum{val code = "3tqxx"} //超级自由行首页
case object SUPERFREETRAVEL_TripGuide extends PageTypeEnum{val code = "3tqxxsh3"} //行程向导页
case object SUPERFREETRAVEL_ChooseResource extends PageTypeEnum{val code = "3tqxxtng"} //选择资源页
case object SUPERFREETRAVEL_Details extends PageTypeEnum{val code = "3tqxx4ot"} //玩法详情页
case object SUPERFREETRAVEL_ChangeTransp extends PageTypeEnum{val code = "3tqxxtnggwh"} //更换交通页
case object SUPERFREETRAVEL_HotelList extends PageTypeEnum{val code = "3tqxxtnge1g"} //酒店列表页
case object SUPERFREETRAVEL_HotelDetail extends PageTypeEnum{val code = "3tqxxtngfdo"} //酒店详情页
case object SUPERFREETRAVEL_ChooseCity extends PageTypeEnum{val code = "3tqxxl4s"} //选择城市
case object SUPERFREETRAVEL_ChooseDate extends PageTypeEnum{val code = "3tqxx909"} //选择日期
case object SUPERFREETRAVEL_ChooseDetail extends PageTypeEnum{val code = "3tqxx02m"} //选择出游日期与人数
case object SUPERFREETRAVEL_FillinOrder extends PageTypeEnum{val code = "3tqxxiax"} //填写订单页



sealed trait PageTypeRegexEnum{def code: Regex}
case object TOPIC_REGEX extends PageTypeRegexEnum{val code = "(3zhTi.*)".r} //专题页模版
case object CHANNEL_REGEX extends PageTypeRegexEnum{val code = "(3PinD.*)".r} //频道页模版
case object SUPER_GO_REGEX extends PageTypeRegexEnum{val code = "(3tqxx.*)".r} //超级自由行模版


case object THEME_INDEX extends PageTypeEnum{val code = "3ulye"} //主题游频道首页
case object THEME_TAG_LIST extends PageTypeEnum{val code = "3vk8j"} //主题游标签页表页
case object THEME_GUESS_ENJOY extends PageTypeEnum{val code = "3p6kn"} //主题游猜你喜欢页
case object ASSOCIATE_PUSH extends PageTypeEnum{val code = "3bnsc"} //关联推送页


//无线端页面技术类型划分H5，和native
sealed trait PageAttributeEnum {def code: String}
case object H5 extends PageAttributeEnum {val code = "H5"} //页面技术类型为H5，其他为native页面
case object NATIVE extends PageAttributeEnum {val code = "NATIVE"}

object LogType extends Enumeration {
  type LogType = Value
  val forward = Value("forward")
  val click = Value("click")
}

object BottonCode extends Enumeration {
  type BottonCode = Value
  val slide = Value("slide")
  val navigation = Value("navigation")
}

object ZBYPitCode extends Enumeration {
  type PitCode = Value
  val banner = Value("sywA01")
  val zbym1ban = Value("zbym1ban")
  val zbym2ind = Value("zbym2ind")
  val zbym3hos = Value("zbym3hos")
  val zbym4reg = Value("zbym4reg")
  val zbym5adv = Value("zbym5adv")
  val zbym6tas = Value("zbym6tas")
}

object TerminalType extends Enumeration {
  type TerminalType = Value
  val wab = Value("2g53")
  val pc = Value("2qw6")
  val others = Value
}

